(Nearly) everything.
There is a ggplot here:
gg-this and gg-thatggplotggplot theme elements
+ elements, limited ability to modify theme() elements, etc.scale_ handles changing how aesthetics are represented in plots
scale_x_scale_y_scale_color_scale_fill_scale_shape_scale_aesthetic_type where type is
continuousdiscretemanualdate, time, datetimeDifferent aesthetics have different scale types available
scale_x-Tabscale_x_ and scale_y_Most commonly:
scale_{xy}_continuous: Continuousscale_{xy}_discrete: Categoricalscale_{xy}_log10: log10 transformationscale_{xy}_sqrt: Square-root transformationscale_{xy}_reverse: Reverse the axisSpecies abundance of electric fish upstream and downstream of the entrance of a tributary in the Amazon basin.
| Tributary | n_Upstream | n_Downstream |
|---|---|---|
| Coari | 5 | 7 |
| Ica | 14 | 19 |
| Japura | 8 | 8 |
| Jutai | 11 | 18 |
| Madeira | 29 | 30 |
| Manacapuru | 5 | 6 |
| Negro | 23 | 24 |
| Purus | 10 | 16 |
| Tapajos | 16 | 20 |
| Tocantins | 10 | 12 |
| Trombetas | 19 | 16 |
| Xingu | 25 | 21 |
n_Upstream and n_Downstream diversity by Tributaryn_Upstream vs. n_Downstreamggplots are additive, so we can “add” to an existing plot.What is the relationship between upstream and downstream diversity?
coord_equal)xlim, ylim)scale_color_ and scale_fill_\nscale_color_ and scale_fill_scale_shape_scale_size_range to control the output scalescale_size_theme() changes aspects of plots?theme for optionsEF_bar +
labs(x = "Stream") +
scale_fill_manual(values = c("darkred", "navy"),
name = "Location",
labels = c("Downstream", "Upstream")) +
theme(axis.text = element_text(size = 9),
axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1),
axis.title.y = element_text(face = "bold"),
axis.title.x = element_blank(),
legend.title = element_text(size = 10, face = "italic"),
legend.text = element_text(size = 9))ggplot(EF, aes(x = n_Upstream,
y = n_Downstream,
color = Tributary)) +
geom_abline(slope = 1, intercept = 0, linetype = "dotted") +
geom_point(size = 5) +
scale_color_viridis_d(guide = guide_legend(ncol = 3,
override.aes = list(size = 2))) +
coord_equal(xlim = c(0, 30), ylim = c(0, 30)) +
labs(x = "Upstream Species",
y = "Downstream Species",
title = "Species Diversity in the Amazon") +
theme(legend.title = element_text(size = 10),
legend.text = element_text(size = 9),
legend.position = c(0.35, 0.175),
legend.box.background = element_rect(color = "black", linewidth = 1),
legend.box.margin = margin(4, 4, 4, 4),
axis.title = element_text(face = "bold"))element_blank() to remove plot elementsx-axis completelyelement_blank() to remove plot elements